{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from scipy import optimize\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 生成模拟数据，进行测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-12.740606    -3.344328     1.573473    -3.3214664   -5.8298826\n",
      "  -6.945669     0.8255291    2.6978302   -7.5362234    6.364052\n",
      "   4.631096     2.9287758   -3.5923767   12.255577     6.64777\n",
      "  -0.17581367   8.305342     8.579206     2.71673     17.302277  ]\n"
     ]
    }
   ],
   "source": [
    "X = np.array(np.arange(100) ,dtype=np.float32)\n",
    "Y = np.array(np.arange(100) ,dtype=np.float32)#此时X和Y其实是相等的，后面加入随机值，尽可能真实模拟实际情况\n",
    "Y +=(np.random.random_sample(100) * 20)# *20指的是，上波动10\n",
    "Y -=20 #下降20，，，y = x+b  -->  y = x - 10\n",
    "print(Y[:20])#查看前20列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9688608829544701 -8.454010568845552\n"
     ]
    }
   ],
   "source": [
    "def residuals(p):\n",
    "    \"计算以p为参数的直线和原始数据之间的误差\"\n",
    "    k,b = p\n",
    "    return Y - (k*X + b)#这其实是 y=kx+b的变形，，y-kx+b = 0\n",
    "\n",
    "r = optimize.leastsq(residuals,[1,0])\n",
    "k,b = r[0]\n",
    "print(k,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAFpCAYAAACMK9MWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHd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1cea4979b38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(6,6))\n",
    "plt.plot(X,Y,'ro',label=\"point\")\n",
    "\n",
    "# 拟合直线\n",
    "x = np.arange(0,100,0.1)\n",
    "y = x*k+b\n",
    "plt.plot(x,y,\"b\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
